package com.kayden.aop.proxy;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

//import org.aopalliance.intercept.MethodInterceptor;
import java.lang.reflect.Method;

public class CGlibMethodInterceptor implements MethodInterceptor {

    private Object target;

    public CGlibMethodInterceptor(Object target) {
        this.target = target;
    }

    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("我开始代理");
        Object invoke = method.invoke(target, objects);
        System.out.println("我结束代理");
        return invoke;
    }
}
